<template>
    <DatePicker v-model="formatValue" ref="datepicker" type="datetimerange" format="yyyy-MM-dd HH:mm:ss" :size="size"
                :time-picker-options="{steps: [1, 15, 60]}" clearable :options="options"
                style="min-width: 270px"></DatePicker>
</template>

<script>
    export default {
        name: "dateTimeRange",
        props: {
            value: {
                type: [Array],
                default: () => []
            },
            size: {
                type: String
            }
        },
        data(){
            return {
                options:{
                    disabledDate(date){
                        return date && date.valueOf() > Date.now() + 86400000;
                    }
                }
            }
        },
        computed: {
            formatValue: {
                get() {
                    return this.value;
                }, set(v) {
                    let publicStringValue = this.$refs['datepicker'].publicStringValue;
                    if (publicStringValue[1].split(" ")[1] === '00:00:00') {
                        publicStringValue[1] = publicStringValue[1].split(" ")[0] + ' ' + '23:59:59';
                    }
                    this.$emit('input', publicStringValue);
                }
            }
        }
    }
</script>

<style scoped>

</style>